-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix multiple schemas in config #193
Conversation
WalkthroughThe update to the configuration loading mechanism involves refining the handling of file lists, specifically schema filenames. There is a restructured approach to initializing and assigning file lists within the configuration function, which suggests an enhancement or fix in how the application manages its configuration files. Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- config/config.go (2 hunks)
Additional comments: 1
config/config.go (1)
- 169-184: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [139-181]
The changes to
LoadConfig
to support multiple schema files by usingStringList
seem correct and well-implemented. Ensure that all parts of the codebase that interact withcfg.SchemaFilename
are updated to handle theStringList
type correctly.Verification successful
The search for usages of
cfg.SchemaFilename
within Go files has returned only the fileconfig/config.go
, which is the file that was modified in the pull request. This suggests that there are no other parts of the codebase usingcfg.SchemaFilename
that would be affected by the change to theStringList
type. Therefore, no further action is required to update other parts of the codebase.
- The changes to
LoadConfig
inconfig/config.go
are consistent with the PR's objective to support multiple schema files.- The usage of
cfg.SchemaFilename
appears to be confined toconfig/config.go
, indicating no immediate downstream effects on other parts of the codebase.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usages of cfg.SchemaFilename to ensure they handle StringList type. rg --type go 'cfg\.SchemaFilename' --files-with-matchesLength of output: 74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- config/config.go (2 hunks)
Additional comments: 2
config/config.go (2)
139-142: The initialization of
files
as aStringList
is correct and follows Go's idiomatic way of declaring and initializing variables.179-180: The assignment of
files
tocfg.SchemaFilename
is correct and reflects the intent to support multiple schema files. This change should be verified to ensure that all parts of the application that usecfg.SchemaFilename
can handle multiple values correctly.Verification successful
Based on the usages of
cfg.SchemaFilename
inconfig/config.go
, it is treated as an iterable, with range loops iterating over its elements. This supports the change to assignfiles
(aStringList
) tocfg.SchemaFilename
, indicating that the application is expected to handle multiple schema filenames correctly.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the application correctly handles multiple schema files. # This script should be run in the root of the repository. rg --type go 'cfg.SchemaFilename' --files-with-matchesLength of output: 71
Script:
#!/bin/bash # Check the usage of 'cfg.SchemaFilename' within 'config/config.go' to determine if it's used as a single string or a list. rg --type go 'cfg.SchemaFilename' config/config.goLength of output: 275
} | ||
} | ||
|
||
files := StringList{} | ||
for _, m := range matches { | ||
if !files.Has(m) { | ||
files = append(files, m) | ||
} | ||
} | ||
|
||
cfg.SchemaFilename = files | ||
} | ||
|
||
cfg.SchemaFilename = files | ||
|
||
models := make(config.TypeMap) | ||
if cfg.Models != nil { | ||
models = cfg.Models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [140-176]
The logic for handling glob patterns and appending unique file paths to files
appears correct. However, ensure that the StringList.Has
method is efficient for larger sets of schema files, as it currently has O(n) complexity for each check.
// Consider using a map for efficient lookups if the number of schema files is large.
Summary by CodeRabbit